﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage_Home.master" AutoEventWireup="true" CodeFile="listproduct.aspx.cs" Inherits="admin_Product_listproduct" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <p>
        <br />
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" CellPadding="3" 
            DataKeyNames="ID_Product" DataSourceID="listproduct" 
            GridLines="Vertical" ShowFooter="True" BackColor="White" 
            BorderColor="#999999" BorderStyle="None" BorderWidth="1px" Height="300px" 
            PageSize="5" 
            Width="5px" onrowcommand="GridView1_RowCommand" 
            onselectedindexchanged="GridView1_SelectedIndexChanged">
            <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
            <Columns>
                <asp:TemplateField HeaderText="ID_Product" SortExpression="ID_Product" 
                    Visible="False">
                    <EditItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("ID_Product") %>'></asp:Label>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lbIDproduct" runat="server" Text='<%# Bind("ID_Product") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="ProductName" HeaderText="ProductName" 
                    SortExpression="ProductName" />
                     <asp:TemplateField HeaderText="Image" SortExpression="Image">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Image") %>'></asp:TextBox>
                    </EditItemTemplate>
                         <ItemTemplate>
                             <asp:Image ID="imgctproduct" runat="server" Height="125px" 
                                 ImageUrl='<%# Eval("Image") %>' Width="105px" />
                         </ItemTemplate>
                    <ControlStyle BorderStyle="None" />
                </asp:TemplateField>
                <asp:BoundField DataField="Quantity" HeaderText="Quantity" 
                    SortExpression="Quantity" />
                <asp:TemplateField HeaderText="Price" SortExpression="Price" Visible="False">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Price") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lbprice" runat="server" Text='<%# Bind("Price") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Product_SaleOff" HeaderText="Product_SaleOff" 
                    SortExpression="Product_SaleOff" />
                <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" 
                    Visible="False" />
                <asp:TemplateField HeaderText="Details" SortExpression="Details" 
                    Visible="False">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Details") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lbDetails" runat="server" Text='<%# Bind("Details") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
               
                <asp:BoundField DataField="TypeProduct_ID" HeaderText="TypeProduct_ID" 
                    SortExpression="TypeProduct_ID" />
                <asp:CommandField ShowSelectButton="True" />
                <asp:CommandField ShowDeleteButton="True" />
            </Columns>
            <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
            <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="Gainsboro" />
        </asp:GridView>
        <asp:SqlDataSource ID="listproduct" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ShoppingOnlineConnectionString %>" 
            SelectCommand="SELECT * FROM [TheStorage]" 
            DeleteCommand="DELETE FROM [TheStorage] WHERE [ID_Product] = @ID_Product" 
            InsertCommand="INSERT INTO [TheStorage] ([ID_Product], [ProductName], [Quantity], [Price], [Product_SaleOff], [Status], [Details], [Image], [TypeProduct_ID]) VALUES (@ID_Product, @ProductName, @Quantity, @Price, @Product_SaleOff, @Status, @Details, @Image, @TypeProduct_ID)" 
            UpdateCommand="UPDATE [TheStorage] SET [ProductName] = @ProductName, [Quantity] = @Quantity, [Price] = @Price, [Product_SaleOff] = @Product_SaleOff, [Status] = @Status, [Details] = @Details, [Image] = @Image, [TypeProduct_ID] = @TypeProduct_ID WHERE [ID_Product] = @ID_Product">
            <DeleteParameters>
                <asp:Parameter Name="ID_Product" Type="String" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:ControlParameter ControlID="txtName" Name="ProductName" 
                    PropertyName="Text" Type="String" />
                <asp:Parameter Name="Quantity" Type="Int32" />
                <asp:Parameter Name="Price" Type="Int32" />
                <asp:Parameter Name="Product_SaleOff" Type="Int32" />
                <asp:Parameter Name="Status" Type="String" />
                <asp:Parameter Name="Details" Type="String" />
                <asp:ControlParameter Name="Image" Type="String" />
                <asp:Parameter Name="TypeProduct_ID" Type="String" />
                <asp:Parameter Name="ID_Product" Type="String" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="ID_Product" Type="String" />
                <asp:Parameter Name="ProductName" Type="String" />
                <asp:Parameter Name="Quantity" Type="Int32" />
                <asp:Parameter Name="Price" Type="Int32" />
                <asp:Parameter Name="Product_SaleOff" Type="Int32" />
                <asp:Parameter Name="Status" Type="String" />
                <asp:Parameter Name="Details" Type="String" />
                <asp:Parameter Name="Image" Type="String" />
                <asp:Parameter Name="TypeProduct_ID" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
        <br />
        <asp:FormView ID="FormView1" runat="server" DataKeyNames="ID_Product" 
            DataSourceID="listproduct" onitemupdating="FormView1_ItemUpdating">
            <EditItemTemplate>
                ID_Product:
                <asp:Label ID="ID_ProductLabel1" runat="server" 
                    Text='<%# Eval("ID_Product") %>' />
                <br />
                ProductName:
                <asp:TextBox ID="ProductNameTextBox" runat="server" 
                    Text='<%# Bind("ProductName") %>' />
                <br />
                Quantity:
                <asp:TextBox ID="QuantityTextBox" runat="server" 
                    Text='<%# Bind("Quantity") %>' />
                <br />
                Price:
                <asp:TextBox ID="PriceTextBox" runat="server" Text='<%# Bind("Price") %>' />
                <br />
                Product_SaleOff:
                <asp:TextBox ID="Product_SaleOffTextBox" runat="server" 
                    Text='<%# Bind("Product_SaleOff") %>' />
                <br />
                Status:
                <asp:TextBox ID="StatusTextBox" runat="server" Text='<%# Bind("Status") %>' />
                <br />
                Details:
                <asp:TextBox ID="DetailsTextBox" runat="server" Text='<%# Bind("Details") %>' />
                <br />
                Image:
                <asp:FileUpload ID="FileUpload1" runat="server" />
                <br />
                TypeProduct_ID:
                <asp:TextBox ID="TypeProduct_IDTextBox" runat="server" 
                    Text='<%# Bind("TypeProduct_ID") %>' />
                <br />
                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                    CommandName="Update" Text="Update" />
&nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" 
                    CommandName="Cancel" Text="Cancel" />
            </EditItemTemplate>
            <InsertItemTemplate>
                ID_Product:
                <asp:TextBox ID="ID_ProductTextBox" runat="server" 
                    Text='<%# Bind("ID_Product") %>' />
                <br />
                ProductName:
                <asp:TextBox ID="ProductNameTextBox" runat="server" 
                    Text='<%# Bind("ProductName") %>' />
                <br />
                Quantity:
                <asp:TextBox ID="QuantityTextBox" runat="server" 
                    Text='<%# Bind("Quantity") %>' />
                <br />
                Price:
                <asp:TextBox ID="PriceTextBox" runat="server" Text='<%# Bind("Price") %>' />
                <br />
                Product_SaleOff:
                <asp:TextBox ID="Product_SaleOffTextBox" runat="server" 
                    Text='<%# Bind("Product_SaleOff") %>' />
                <br />
                Status:
                <asp:TextBox ID="StatusTextBox" runat="server" Text='<%# Bind("Status") %>' />
                <br />
                Details:
                <asp:TextBox ID="DetailsTextBox" runat="server" Text='<%# Bind("Details") %>' />
                <br />
                Image:
                <asp:TextBox ID="ImageTextBox" runat="server" Text='<%# Bind("Image") %>' />
                <br />
                TypeProduct_ID:
                <asp:TextBox ID="TypeProduct_IDTextBox" runat="server" 
                    Text='<%# Bind("TypeProduct_ID") %>' />
                <br />
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                    CommandName="Insert" Text="Insert" />
                &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancel" />
            </InsertItemTemplate>
            <ItemTemplate>
                ID_Product:
                <asp:Label ID="ID_ProductLabel" runat="server" 
                    Text='<%# Eval("ID_Product") %>' />
                <br />
                ProductName:
                <asp:Label ID="ProductNameLabel" runat="server" 
                    Text='<%# Bind("ProductName") %>' />
                <br />
                Quantity:
                <asp:Label ID="QuantityLabel" runat="server" Text='<%# Bind("Quantity") %>' />
                <br />
                Price:
                <asp:Label ID="PriceLabel" runat="server" Text='<%# Bind("Price") %>' />
                <br />
                Product_SaleOff:
                <asp:Label ID="Product_SaleOffLabel" runat="server" 
                    Text='<%# Bind("Product_SaleOff") %>' />
                <br />
                Status:
                <asp:Label ID="StatusLabel" runat="server" Text='<%# Bind("Status") %>' />
                <br />
                Details:
                <asp:Label ID="DetailsLabel" runat="server" Text='<%# Bind("Details") %>' />
                <br />
                Image:
                <asp:Image ID="Image2" runat="server" Height="115px" 
                    ImageUrl='<%# Eval("Image") %>' Width="114px" />
                <br />
                TypeProduct_ID:
                <asp:Label ID="TypeProduct_IDLabel" runat="server" 
                    Text='<%# Bind("TypeProduct_ID") %>' />
                <br />
                <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                    CommandName="Edit" Text="Edit" />
&nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                    CommandName="Delete" Text="Delete" />
                &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                    CommandName="New" Text="New" />
            </ItemTemplate>
        </asp:FormView>
        <table style="width: 100%; height: 252px;">
    <tr>
            <td class="style3">
                </td>
            <td class="style4">
                <asp:Label ID="lbIDtype" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                </td>
            <td class="style2">
                <asp:TextBox ID="txtName" runat="server" Enabled="False"></asp:TextBox>
            </td>
            <td rowspan="5">
                <asp:Image ID="imgProduct" runat="server" Height="236px" style="margin-left: 0px" 
                    Width="196px"  />
                <br />
                
                <asp:FileUpload ID="fuImage" runat="server" Visible="False" Width="195px"   
                     />
                
                <br />
            </td>
        </tr>
       
        <tr>
            <td class="style3">
                </td>
            <td class="style4">
                <asp:DropDownList ID="ddlType" runat="server" DataSourceID="drtype" 
                    DataTextField="TypeProduct_Name" DataValueField="TypeProduct_ID" Height="29px" 
                    Width="127px" Enabled="False">
                </asp:DropDownList>
                <asp:SqlDataSource ID="drtype" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ShoppingOnlineConnectionString %>" 
                    SelectCommand="SELECT * FROM [ProductType]"></asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td class="style2">
                <asp:TextBox ID="txtQuantity" runat="server" Enabled="False"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td class="style2">
                <asp:TextBox ID="txtPrice" runat="server" Enabled="False"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td class="style2">
                <asp:TextBox ID="txtProduct_SaleOff" runat="server" 
                    Enabled="False"></asp:TextBox>
            </td>
        </tr>
         <tr>
            <td>
                &nbsp;</td>
            <td class="style2" colspan="2">
                <asp:TextBox ID="txtDetails" runat="server" Height="54px" TextMode="MultiLine" 
                    Width="406px" Enabled="False"></asp:TextBox>
            </td>
        </tr>
         <tr>
            <td>
                &nbsp;</td>
            <td class="style2" align="right">
                <asp:Button ID="btnSave" runat="server" Text="Save" Visible="False" 
                    onclick="btnSave_Click" />
                <asp:Button ID="btnUpdate" runat="server" Text="Update" onclick="btnUpdate_Click" 
                     />
            </td>
             <td>
                 <asp:Button ID="btnCancel" runat="server" Text="Cancel" Visible="False" />
             </td>
        </tr>
    </table>
    </p>
    <p>
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
            Text="Addproduct" />
    </p>
</asp:Content>

